<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>colorizer Docs</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>colorizer</h1>


<ul>
  <li><a href="../index.html">Index</a></li>
</ul>



<h2>Modules</h2>
<ul class="nowrap">
  <li><a href="../modules/colorizer.html">colorizer</a></li>
  <li><a href="../modules/colorizer.buffer.html">buffer</a></li>
  <li><a href="../modules/colorizer.color.html">color</a></li>
  <li><a href="../modules/colorizer.config.html">config</a></li>
  <li><a href="../modules/colorizer.constants.html">constants</a></li>
  <li><a href="../modules/colorizer.matcher.html">matcher</a></li>
  <li><a href="../modules/colorizer.parser.rgb_hex.html">parser.rgb_hex</a></li>
  <li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
  <li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
  <li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
  <li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
  <li><a href="../modules/colorizer.parser.tailwind_names.html">parser.tailwind_names</a></li>
  <li><a href="../modules/colorizer.sass.html">sass</a></li>
  <li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
  <li><strong>trie</strong></li>
  <li><a href="../modules/colorizer.usercmds.html">usercmds</a></li>
  <li><a href="../modules/colorizer.utils.html">utils</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>colorizer.trie</code></h1>
<p>Trie implementation in luajit.</p>
<p>
 This module provides a Trie data structure implemented in LuaJIT with efficient memory handling.
 It supports operations such as inserting, searching, finding the longest prefix, and converting the Trie into a table format.
 The implementation uses LuaJIT's Foreign Function Interface (FFI) for optimized memory allocation.
 Dynamic Allocation:
 - The `character` array in each Trie node is dynamically allocated using a double pointer (`struct Trie**`).
 - Each Trie node contains:
   - A `bool is_leaf` field to indicate whether the node represents the end of a string.
   - A `struct Trie** character` pointer that references the dynamically allocated array.
 - Memory for the `character` array is allocated only when the node is created.
 - The `character` array can support up to 256 child nodes, corresponding to ASCII values.
 - Each slot in the array is initialized to `NULL` and represents a potential child node.
 - Memory for each node and its `character` array is allocated using `ffi.C.malloc` and freed recursively using `ffi.C.free`.</p>



<br/>
<br/>




</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/lunarmodules/LDoc">LDoc 1.5.0</a></i>
<i style="float:right;">Last updated - January </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
